﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfStudy.Animation
{
    /// <summary>
    /// WaterLoad.xaml 的交互逻辑
    /// </summary>
    public partial class WaterLoad : Window,INotifyPropertyChanged
    {
        private double value;
        public double Value
        {
            get { return value; }
            set {
                this.value = value;
                if (PropertyChanged!=null)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Value"));
                }
            }
        }

        public WaterLoad()
        {
            InitializeComponent();
            InitalizeAnamition();
            Value = 20;
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void InitalizeAnamition()
        {
            DoubleAnimation angle = new DoubleAnimation();
            angle.From = 0;

            angle.To = 720;

            Duration duration = new Duration(TimeSpan.FromSeconds(20));
            angle.Duration = duration;

            angle.RepeatBehavior = RepeatBehavior.Forever;

            rt.BeginAnimation(RotateTransform.AngleProperty, angle);
           
        }
    }
    public class ValueToXConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double TransY = (double)value;
            double result = 340 - 270 * (TransY / 100);
            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }
}
